package top.jfunc.common.event.core;

import java.util.EventObject;

/**
 * Class to be extended by all application events. Abstract as it doesn't make
 * sense for generic events to be published directly.
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 */
public abstract class ApplicationEvent extends EventObject{

    /** use serialVersionUID from Spring 1.2 for interoperability */
    private static final long serialVersionUID = 7099057708183571937L;

    /** System time when the event happened */
    private final long        timestamp;

    /**
     * Create a new ApplicationEvent.
     * 
     * @param source
     *            the component that published the event (never {@code null})
     */
    public ApplicationEvent(Object source){
        super(source);
        this.timestamp = System.currentTimeMillis();
    }

    /**
     * Return the system time in milliseconds when the event happened.
     * 
     * @return Return the system time in milliseconds
     */
    public final long getTimestamp(){
        return this.timestamp;
    }

}